package Test;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;
import java.util.Scanner;

public class Dome {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        // 获取系统类加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        InputStream is = systemClassLoader.getResourceAsStream("prop.properties");
        // 创建Properties集合
        Properties prop = new Properties();
        // 将文件中数据读取到集合中
        prop.load(is);
        is.close();

        Scanner sc = new Scanner(System.in);
        String name = sc.next();
        int age = sc.nextInt();

        //
        // 获取对象
        Class clazz = Class.forName(prop.getProperty("classname"));
        // 获取构造方法对象
        Constructor constructor = clazz.getConstructor(String.class,int.class);
        // 利用newInstance创建对象
        Object o = constructor.newInstance(name,age);
        // 获取方法对象
        Method methodname = clazz.getMethod(prop.getProperty("methodname"));
        // 运行方法
        methodname.invoke(o);

    }
}
